Load all required libraries.

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.3     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(broom)

Read in raw data from RDS.

raw_data <- readRDS("./year2.RDS")

Make a few small modifications to names and data for visualizations.

final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
  rename(Facility = wrf) %>%
  mutate(Facility = recode(Facility, 
                           "NO" = "WRF A",
                           "MI" = "WRF B",
                           "CC" = "WRF C"))

Seperate the data by gene target to ease layering in the final plot

#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>% 
  select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
  group_by(date) %>% summarise_if(is.numeric, mean)

#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]

only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]

Build the main plot

      #first layer is the background epidemic curve
        p1 <- only_background %>%
              plotly::plot_ly() %>%
              plotly::add_trace(x = ~date, y = ~new_cases_clarke, 
                                type = "bar", 
                                hoverinfo = "text",
                                text = ~paste('</br> Date: ', date,
                                                     '</br> Daily Cases: ', new_cases_clarke),
                                alpha = 0.5,
                                name = "Daily Reported Cases",
                                color = background_color,
                                colors = background_color,
                                showlegend = FALSE) %>%
            layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
            layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
        
        #renders the main plot layer two as seven day moving average
        p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke, 
                             type = "scatter",
                             mode = "lines",
                             hoverinfo = "text",
                            text = ~paste('</br> Date: ', date,
                                                     '</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
                             name = "Seven Day Moving Average Athens",
                             line = list(color = seven_day_ave_color),
                             showlegend = FALSE)
      

        
        #renders the main plot layer three as positive target hits
        
        p2 <- plotly::plot_ly() %>%
          plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
                                       type = "scatter",
                                       mode = "markers",
                                       hoverinfo = "text",
                                       text = ~paste('</br> Date: ', date,
                                                     '</br> Facility: ', Facility,
                                                     '</br> Target: ', target,
                                                     '</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
                                       data = only_n1,
                                       symbol = ~Facility,
                                       marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
                                       showlegend = FALSE) %>%
          plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
                                       type = "scatter",
                                       mode = "markers",
                                       hoverinfo = "text",
                                       text = ~paste('</br> Date: ', date,
                                                     '</br> Facility: ', Facility,
                                                     '</br> Target: ', target,
                                                     '</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
                                       data = only_n2,
                                       symbol = ~Facility,
                                       marker = list(color = '#D95F02', size = 8, opacity = 0.65),
                                       showlegend = FALSE) %>%
            layout(yaxis = list(title = "SARS CoV-2 Copies/L", 
                                 showline = TRUE,
                                 type = "log",
                                 dtick = 1,
                                 automargin = TRUE)) %>%
            layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
        
        #adds the limit of detection dashed line
        p2 <- p2 %>% plotly::add_segments(x = as.Date("2021-06-30"), 
                                          xend = ~max(date + 10), 
                                          y = 3571.429, yend = 3571.429,
                                          opacity = 0.35,
                                          line = list(color = "black", dash = "dash")) %>%
          layout(annotations = list(x = as.Date("2021-06-30"), y = 3.8, xref = "x", yref = "y", 
                                    text = "Limit of Detection", showarrow = FALSE))

        

        p1
        p2

Combine the two main plot pieces as a subplot

#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")

#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")


#rejoin the old data frames then seperate in to averages for each plant. 
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
  select(c(date, mean_total_copies)) %>%
  group_by(date) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
  select(c(date, mean_total_copies)) %>%
  group_by(date) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
  select(c(date, mean_total_copies)) %>%
  group_by(date) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)

Build loess smoothing figures figures

This makes the individual plots

#**************************************WRF A PLOT**********************************************
#add trendlines 
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) + 
  stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77', 
              span = 0.3, n = 204)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'

fit_botha
##   [1] 11.53161 11.56995 11.60796 11.64567 11.68313 11.72040 11.75752 11.79442
##   [9] 11.83103 11.86734 11.90335 11.93906 11.97449 12.00962 12.04446 12.07935
##  [17] 12.11455 12.14990 12.18528 12.22053 12.25552 12.29011 12.32416 12.35752
##  [25] 12.39005 12.42162 12.45209 12.47972 12.50374 12.52543 12.54607 12.56693
##  [33] 12.58930 12.61444 12.64161 12.66909 12.69670 12.72429 12.75168 12.77871
##  [41] 12.80521 12.83298 12.86325 12.89507 12.92747 12.95948 12.99014 13.01846
##  [49] 13.04350 13.06427 13.08415 13.10614 13.12872 13.15036 13.16954 13.18475
##  [57] 13.19445 13.20044 13.20524 13.20844 13.20961 13.20834 13.20420 13.19679
##  [65] 13.18471 13.16733 13.14538 13.11955 13.09056 13.05913 13.02596 12.99176
##  [73] 12.95726 12.92315 12.89016 12.85899 12.82661 12.79048 12.75203 12.71267
##  [81] 12.67385 12.63697 12.60349 12.56895 12.52951 12.48749 12.44517 12.40486
##  [89] 12.36888 12.33952 12.31538 12.29344 12.27355 12.25553 12.23926 12.22456
##  [97] 12.21128 12.19928 12.18839 12.18163 12.18078 12.18382 12.18876 12.19358
## [105] 12.19629 12.19487 12.19145 12.18922 12.18781 12.18684 12.18594 12.18471
## [113] 12.18280 12.17965 12.17523 12.16988 12.16396 12.15782 12.15181 12.14628
## [121] 12.14158 12.13807 12.13610 12.13601 12.13817 12.14228 12.14768 12.15419
## [129] 12.16161 12.16973 12.17838 12.18733 12.20064 12.22069 12.24480 12.27031
## [137] 12.29455 12.31485 12.32854 12.33660 12.34201 12.34508 12.34614 12.34551
## [145] 12.34351 12.34046 12.33668 12.33250 12.32824 12.32422 12.32075 12.31817
## [153] 12.31679 12.31025 12.29474 12.27440 12.25334 12.23571 12.22563 12.22723
## [161] 12.23536 12.24278 12.25055 12.25968 12.27122 12.28620 12.30566 12.33160
## [169] 12.36458 12.40349 12.44720 12.49460 12.54456 12.59596 12.64768 12.69861
## [177] 12.74762 12.79359 12.83540 12.87193 12.90206 12.92892 12.95619 12.98359
## [185] 13.01081 13.03756 13.06355 13.08849 13.11208 13.13403 13.15405 13.17184
## [193] 13.18711 13.19957 13.20893 13.21548 13.21980 13.22196 13.22204 13.22011
## [201] 13.21627 13.21059 13.20314 13.19401
#assign fits to a vector
both_trenda <- fit_botha

#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax

#reassign dataframes (just to be safe)
work_botha <- wrfa_both

#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date

#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
  plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
                    data = smooth_frame_botha,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_botha,
                                  '</br> Median Log Copies: ', round(both_trenda, digits = 2)),
                    line = list(color = '#1B9E77', size = 8, opacity = 0.65),
                    showlegend = FALSE) %>%
     layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
                    showlegend = FALSE,
                    opacity = 0.25,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
                                  '</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
                                  '</br> Min Log Copies: ', round(both_ymina, digits = 2)),
                    name = "",
                    fillcolor = '#1B9E77',
                    line = list(color = '#1B9E77')) %>%
                layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies", 
                                 showline = TRUE,
                                 automargin = TRUE)) %>%
                layout(xaxis = list(title = "Date")) %>%
                layout(title = "WRF A") %>%
  plotly::add_markers(x = ~date, y = ~log_total_copies_both,
                      data = wrfa_both,
                       hoverinfo = "text",
                       showlegend = FALSE,
                       text = ~paste('</br> Date: ', date, 
                                     '</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
                       marker = list(color = '#1B9E77', size = 6, opacity = 0.65))

p_wrf_a
save(p_wrf_a, file = "./site_objects/wrf_a_year2.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines 
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) + 
  stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02', 
              span = 0.3, n = 204)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'

fit_bothb
##   [1] 10.68848 10.78452 10.87840 10.97024 11.06014 11.14822 11.23457 11.31921
##   [9] 11.40202 11.48292 11.56182 11.63864 11.71329 11.78570 11.85577 11.92367
##  [17] 11.98957 12.05345 12.11528 12.17503 12.23266 12.28814 12.34145 12.39254
##  [25] 12.44139 12.48797 12.53224 12.57461 12.61539 12.65440 12.69148 12.72647
##  [33] 12.75919 12.78948 12.81497 12.83451 12.84972 12.86223 12.87367 12.88565
##  [41] 12.89981 12.91363 12.92397 12.93151 12.93694 12.94093 12.94418 12.94737
##  [49] 12.95118 12.95629 12.96378 12.97345 12.98411 12.99456 13.00360 13.01005
##  [57] 13.01269 13.01062 13.00457 12.99585 12.98574 12.97552 12.96649 12.95993
##  [65] 12.95459 12.94842 12.94156 12.93416 12.92636 12.91829 12.91011 12.90194
##  [73] 12.89393 12.88622 12.87896 12.87227 12.86891 12.87009 12.87368 12.87757
##  [81] 12.87962 12.87769 12.86968 12.85758 12.84472 12.83095 12.81612 12.80008
##  [89] 12.78267 12.76375 12.74021 12.71020 12.67545 12.63770 12.59866 12.56008
##  [97] 12.52367 12.49117 12.46431 12.44370 12.42750 12.41379 12.40062 12.38606
## [105] 12.36818 12.34505 12.32022 12.29773 12.27634 12.25480 12.23189 12.20636
## [113] 12.17697 12.13966 12.09271 12.03844 11.97913 11.91710 11.85463 11.79404
## [121] 11.73761 11.68766 11.64647 11.61636 11.59961 11.59076 11.58360 11.57935
## [129] 11.57923 11.58448 11.59631 11.61595 11.65372 11.71375 11.78804 11.86854
## [137] 11.94724 12.01610 12.06710 12.10734 12.14895 12.19148 12.23446 12.27742
## [145] 12.31988 12.36140 12.40149 12.43970 12.47555 12.50858 12.53832 12.56430
## [153] 12.58606 12.59750 12.59612 12.58688 12.57472 12.56457 12.56140 12.57013
## [161] 12.58292 12.59025 12.59452 12.59815 12.60356 12.61314 12.62932 12.65296
## [169] 12.68264 12.71732 12.75597 12.79757 12.84109 12.88549 12.92974 12.97283
## [177] 13.01370 13.05135 13.08473 13.11282 13.13458 13.15261 13.17008 13.18683
## [185] 13.20270 13.21755 13.23121 13.24353 13.25435 13.26353 13.27089 13.27630
## [193] 13.27958 13.28060 13.27918 13.27550 13.26985 13.26228 13.25282 13.24153
## [201] 13.22845 13.21361 13.19707 13.17888
#assign fits to a vector
both_trendb <- fit_bothb

#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax

#reassign dataframes (just to be safe)
work_bothb <- wrfb_both

#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date

#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
  plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
                    data = smooth_frame_bothb,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothb,
                                  '</br> Median Log Copies: ', round(both_trendb, digits = 2)),
                    line = list(color = '#D95F02', size = 8, opacity = 0.65),
                    showlegend = FALSE) %>%
     layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
                    showlegend = FALSE,
                    opacity = 0.25,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
                                  '</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
                                  '</br> Min Log Copies: ', round(both_yminb, digits = 2)),
                    name = "",
                    fillcolor = '#D95F02',
                    line = list(color = '#D95F02')) %>%
                layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies", 
                                 showline = TRUE,
                                 automargin = TRUE)) %>%
                layout(xaxis = list(title = "Date")) %>%
                layout(title = "WRF B") %>%
  plotly::add_markers(x = ~date, y = ~log_total_copies_both,
                      data = wrfb_both,
                       hoverinfo = "text",
                       showlegend = FALSE,
                       text = ~paste('</br> Date: ', date, 
                                     '</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
                       marker = list(color = '#D95F02', size = 6, opacity = 0.65))

p_wrf_b
save(p_wrf_b, file = "./site_objects/wrf_b_year2.rda")

#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************

extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) + 
  stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A', 
              span = 0.3, n = 204)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'

fit_bothc
##   [1] 10.73398 10.81555 10.89507 10.97233 11.04712 11.11923 11.18845 11.25498
##   [9] 11.31921 11.38115 11.44086 11.49836 11.55370 11.60691 11.65804 11.70600
##  [17] 11.74999 11.79043 11.82773 11.86231 11.89459 11.92500 11.95394 11.98184
##  [25] 12.00912 12.03620 12.06349 12.09127 12.11926 12.14709 12.17440 12.20081
##  [33] 12.22595 12.24944 12.26986 12.28684 12.30163 12.31548 12.32963 12.34533
##  [41] 12.36382 12.38553 12.40948 12.43488 12.46092 12.48680 12.51172 12.53486
##  [49] 12.55543 12.57262 12.58696 12.59966 12.61091 12.62090 12.62983 12.63790
##  [57] 12.64529 12.65488 12.66811 12.68302 12.69765 12.71006 12.71827 12.72035
##  [65] 12.71609 12.70710 12.69406 12.67769 12.65867 12.63770 12.61548 12.59272
##  [73] 12.57010 12.54833 12.52811 12.51013 12.49338 12.47639 12.45918 12.44176
##  [81] 12.42414 12.40634 12.38837 12.37085 12.35405 12.33749 12.32071 12.30324
##  [89] 12.28459 12.26430 12.24078 12.21357 12.18394 12.15314 12.12244 12.09310
##  [97] 12.06636 12.04350 12.02577 12.01020 11.99360 11.97685 11.96084 11.94646
## [105] 11.93459 11.92614 11.92265 11.92403 11.92867 11.93498 11.94135 11.94619
## [113] 11.94788 11.94998 11.95645 11.96631 11.97860 11.99234 12.00656 12.02029
## [121] 12.03255 12.04238 12.04879 12.05083 12.04751 12.03323 12.00636 11.97182
## [129] 11.93456 11.89951 11.87162 11.85583 11.84902 11.84446 11.84165 11.84009
## [137] 11.83927 11.83869 11.83785 11.83592 11.83258 11.82812 11.82282 11.81696
## [145] 11.81082 11.80469 11.79885 11.79357 11.78916 11.78588 11.78401 11.78385
## [153] 11.78568 11.78663 11.78485 11.78211 11.78020 11.78089 11.78596 11.79719
## [161] 11.81124 11.82426 11.83728 11.85133 11.86747 11.88671 11.91009 11.94013
## [169] 11.97781 12.02192 12.07123 12.12452 12.18055 12.23812 12.29599 12.35294
## [177] 12.40774 12.45917 12.50601 12.54703 12.58100 12.61129 12.64185 12.67235
## [185] 12.70246 12.73187 12.76024 12.78726 12.81259 12.83591 12.85689 12.87522
## [193] 12.89056 12.90259 12.91098 12.91613 12.91873 12.91885 12.91657 12.91196
## [201] 12.90512 12.89611 12.88502 12.87193
#assign fits to a vector
both_trendc <- fit_bothc

#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax

#reassign dataframes (just to be safe)
work_bothc <- wrfc_both

#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date

#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
  plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
                    data = smooth_frame_bothc,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothc,
                                  '</br> Median Log Copies: ', round(both_trendc, digits = 2)),
                    line = list(color = '#E7298A', size = 8, opacity = 0.65),
                    showlegend = FALSE) %>%
     layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
                    showlegend = FALSE,
                    opacity = 0.25,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
                                  '</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
                                  '</br> Min Log Copies: ', round(both_yminc, digits = 2)),
                    name = "",
                    fillcolor = '#E7298A',
                    line = list(color = '#E7298A')) %>%
                layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies", 
                                 showline = TRUE,
                                 automargin = TRUE)) %>%
                layout(xaxis = list(title = "Date")) %>%
                layout(title = "WRF C") %>%
  plotly::add_markers(x = ~date, y = ~log_total_copies_both,
                      data = wrfc_both,
                       hoverinfo = "text",
                       showlegend = FALSE,
                       text = ~paste('</br> Date: ', date, 
                                     '</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
                       marker = list(color = '#E7298A', size = 6, opacity = 0.65))

p_wrf_c
save(p_wrf_c, file = "./site_objects/wrf_c_year2.rda")

keeping in case

#save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
#save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
#save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
#save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
#save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
#save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
#save(both_ymina, file = "./plotly_objs/both_ymina.rda")
#save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")

#save(both_yminb, file = "./plotly_objs/both_yminb.rda")
#save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")

#save(both_yminc, file = "./plotly_objs/both_yminc.rda")
#save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")